package org.shiro.auth.client.filter;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;

public class AccessTokenRpc extends Rpcable<Boolean> {

  private static String isValidUri    = "/isValid";
  private static String isConsumedUri = "/isConsumed";

  public Boolean isValid(String accessToken) throws ClientProtocolException, IOException {
    if (StringUtils.isBlank(accessToken)) {
      return false;
    }
    return call(ConfigUtil.getHost() + isValidUri + "?accessToken=" + accessToken).get(0);
  }

  public Boolean isConsumed(String accessToken) throws ClientProtocolException, IOException {
    if (StringUtils.isBlank(accessToken)) {
      return false;
    }
    return call(ConfigUtil.getHost() + isConsumedUri + "?accessToken=" + accessToken).get(0);
  }
}
